package com.pwc.XMLConversion.Controller;


import java.io.IOException;
import java.util.Locale;
import java.util.Map;

import org.apache.xmlbeans.XmlException;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;


import com.pwc.XMLConversion.Soap.Client;

/**
 * Handles requests for the application home page.
 */
@Controller
public class HomeController {
	
	
	private Client client=new Client();
	
	/**
	 * Simply selects the home view to render by returning its name.
	 */
	@RequestMapping(value = "/", method = RequestMethod.GET)
	public String home(Locale locale, Model model) {
		
		
		return "home";
	}
	
	
	
	@RequestMapping(value = "/", method = RequestMethod.POST)
	public String home(String URL,Model model) {
		
		
		
		client.InitialProject(URL);
		
		Map<String, String> map=client.GetOperationMap();
		
		model.addAttribute("Operations", map);
		
		System.out.println(URL);
		
		return "operations";
	}

	
	
	
	@RequestMapping(value = "/ajax", method = RequestMethod.GET)
	public String ajax(String XML,Model model){
		
		
	//	client.Process(XML, "https://wd2-impl-services1.workday.com/ccx/service/pwc_dpt1/Staffing/v25.0");
		
	//	System.out.println(XML);
		
		
		return "ajax";
	}
	


	public Client getClient() {
		return client;
	}



	public void setClient(Client client) {
		this.client = client;
	}
	
	
}
